<template>
  <div class="app-container" v-loading="pageLoading">
    <div class="filter-container">
      <el-input style="width: 340px" placeholder="输入产品序号按回车" clearable class="filter-item"
        @keyup.enter.native="research" @clear="research" v-model="queryString">
        <template slot="prepend">产品序号</template>
      </el-input>
      <el-button class="filter-item" type="success" plain @click="research">查询</el-button>
    </div>
    <el-tabs v-model="currentTab" @tab-click="tabClick">
      <el-tab-pane label="基本信息" name="tab1">
        <basic-info :sn="querySn" @after-getsn="afterGetSnData"></basic-info>
      </el-tab-pane>
      <el-tab-pane label="工单信息" name="tab2">
        <mo-info :mo_no="mo_no"></mo-info>
      </el-tab-pane>
      <el-tab-pane label="工艺流程" name="tab3">
        <route-info ref="tab3" :routeId="route_id"></route-info>
      </el-tab-pane>
      <el-tab-pane label="捡料记录" name="tab4">
        <wip-keyparts :sn="sn"></wip-keyparts>
      </el-tab-pane>
      <el-tab-pane label="维修记录" name="tab5">
        <repair :sn="sn"></repair>
      </el-tab-pane>
      <el-tab-pane label="换料记录" name="tab6">
        <change-keyparts :sn="sn"></change-keyparts>
      </el-tab-pane>
      <el-tab-pane label="操作日志" name="tab7">
        <wip-log :sn="sn"></wip-log>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import commonMixin from '@/views/_common/mixin'
import basicInfo from '@/views/components/snInfo/basicInfo'
import wipKeyparts from '@/views/components/snInfo/wipKeyparts'
import changeKeyparts from '@/views/components/snInfo/changeKeyparts'
import wipLog from '@/views/components/snInfo/wipLog'
import repair from '@/views/components/snInfo/repair'
import moInfo from '@/views/components/moManageInfo/tab1'
import routeInfo from '@/views/components/moManageInfo/tab3'
export default {
  mixins: [commonMixin],
  components: { basicInfo, moInfo, routeInfo, wipKeyparts, changeKeyparts, wipLog, repair },
  data() {
    return {
      queryString: null,
      currentTab: 'tab1',
      querySn: null,
      sn: null,
      bom_id: null,
      mo_no: null,
      route_id: null,
    }
  },
  methods: {
    tabClick(tab) {
      if (tab.name == 'tab3') {
        this.$refs.tab3.refresh()
      }
    },
    research() {
      //  搜索条件变化处理
      this.currentTab = 'tab1'
      this.querySn = this.queryString
    },
    afterGetSnData({ mo_no, route_id, serial_number }) {
      this.mo_no = mo_no
      this.route_id = route_id
      this.sn = serial_number
    },
  },
  created: function () {
    if (this.$route.params && this.$route.params.id) {
      this.queryString = this.$route.params.id
    }
    this.querySn = this.queryString
  },
}
</script>

<style scoped>
</style>
